﻿using System.Web;
using ElectronicCommerce.Framework.ExceptionManagement.Interface;

namespace ElectronicCommerce.Framework.ExceptionManagement.MessageHandler
{

    /// <summary>
    /// WebMessage 的摘要说明。
    /// </summary>
    public class WebMessage : IMessage
    {
        private ExHandlerBase handler;

        public WebMessage(ExHandlerBase handler)
        {
            this.handler = handler;
        }
        public void ShowMessage(string strMessage)
        {
            strMessage = strMessage.Replace("'", "\"");
            string strmsg = "<script>javascript:alert('" + strMessage + "')</script>";

            System.Web.HttpContext.Current.Response.Write(strmsg);
        }

        public void ShowMessage(string strMessage, MessageBoxType messageType)
        {
            if (messageType == MessageBoxType.Error)
            {
                ShowMessage(strMessage);
            }
            else
            {
                HttpContext.Current.Response.Redirect(string.Format(handler.ExHanlderConfig.DirectUrlFormat, strMessage));
            }
        }
    }
}
